package com.io.printstream;

import org.junit.Test;

import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.io.PrintWriter;

/**
 * 打印流
 */
public class PrintStream_ {
    public static void main(String[] args) {
        System.out.println("这是普通打印流");

        PrintStream out = System.out;
        out.println("测试内容");
        String path = "E:\\test\\print.txt";
        // 把打印的内容写入指定的文件内
        try {
            System.setOut(new PrintStream(path));
            // 打印内容
            System.out.println("记录到文件里面去！");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
